home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Media 22
/
PC MEDIA CD22.iso
/
share
/
prog
/
txtmenu1
/
siren.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-01
|
4KB
|
181 lines
/*
About TXTMENU
This program is to generate a txt-menu in DOS. It is mainly for users to
develop their own txt-based menu. It reads the .cfg file to get the menu
contents and return diffrerent value to indicate the select result.
It has wonderful sound effect and some time counting facility. Besides,
it includes all SOURCE CODE !
To start it just type the exe file and the program will work.
With SOURCE CODE , you can easily modify it for your own purpose.
You can distribute the source code freely only together with this readme
file. Since this is a shareware, you are required to register in order
to use it in your own program. It will only cost you $50.
However, if you do not like to pay so much, you can also pay as much as you
wish to register. Just think the time and energe you will save by this
program !
After you register for this program, you will get permission to
include the source code to your own program. Besides,you will also
get more detailed comments of the source code and you can get answers
from author about any programming problems without extra fee.
Money and Check should mail to:
Mr. Yongyong Xu,
1940 Howard Street. Apt. 333,
Kalamazoo, MI 49008
U.S.A.
Telephone: (616) 387-7569
EMail: yxu@cs.wmich.edu (prefered)
or
99xu1@grog.lab.cc.wmich.edu
When you cannot reach me by the above address, try the next:
-----------------------------------------------------------------------
<Permanet Home Address>
Mr. Xu Yongyong,
Building 34 Room 604,
HuayuanXinCun , Chang Zhou
Jiang Su Province 213016
P.R.China
Tel:(86)-(519)-(328-0177)
*/
//#define DELAY 10000
//#define RATE 10
#include "siren.h"
void siren0(unsigned int delays, unsigned int rate );
void siren1(unsigned int delays, unsigned int rate );
void siren2(unsigned int delays );
void siren3(unsigned int delays );
void frequency(int freq, unsigned int delays );
void siren(int i, unsigned int delays, unsigned int rate )
{
switch (i) {
case 0:
siren0(delays, rate );
break;
case 1:
siren1(delays, rate );
break;
case 2:
siren2(delays);
break;
case 3:
siren3(delays);
break;
}
};
void siren0(unsigned int delays, unsigned int rate )
{
unsigned i,freq;
union {
long divisior;
unsigned char c[2];
} count;
unsigned char p;
p=inportb (97);
outportb(97,p | 3 );
for (freq=1000; freq<3000; freq +=rate ) {
count.divisior = 1193280 / freq;
outportb ( 67, 182);
outportb ( 66, count.c[0]);
outportb ( 66, count.c[1]);
// for (i=0; i<delays; ++i ) ;
delay ( delays / 1000);
}
for ( ; freq> 1000; freq -=rate ) {
count.divisior = 1193280 / freq;
outportb ( 67, 182);
outportb ( 66, count.c[0]);
outportb ( 66, count.c[1]);
// for (i=0; i<delays; ++i ) ;
delay ( delays / 1000);
}
outportb (97,p);
}
void siren1(unsigned int delays, unsigned int rate)
// laser blaster
{
unsigned i,freq;
union {
long divisior;
unsigned char c[2];
} count;
unsigned char p;
p=inportb (97);
outportb(97,p | 3 );
for (freq=3000;freq>1000; freq -=rate ) {
count.divisior = 1193280 / freq;
outportb ( 67, 182);
outportb ( 66, count.c[0]);
outportb ( 66, count.c[1]);
// for (i=0; i<delays; ++i ) ;
delay ( delays / 1000);
}
outportb (97,p);
}
void siren2(unsigned int delays )
// random sound , continue
{
int freq;
do {
do {
freq = rand();
} while (freq >5000);
frequency ( freq , delays );
} while ( !kbhit());
}
void siren3(unsigned int delays )
// random sound , not continue
{
int freq;
do {
freq = rand();
} while (freq >5000);
frequency ( freq , delays );
}
void frequency(int freq, unsigned int delays )
{
unsigned i;
union {
long divisior;
unsigned char c[2];
} count;
unsigned char p;
count.divisior = 1193280 / freq;
outportb ( 67, 182);
outportb ( 66, count.c[0]);
outportb ( 66, count.c[1]);
p=inportb (97);
outportb (97,p | 3 );
// for (i=0; i<delays; ++i ) ;
delay ( delays / 200);
outportb (97,p);
}